package com.itheima.controller;

import com.itheima.pojo.ClazzInfo;
import com.itheima.pojo.JobInfo;
import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import com.itheima.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private EmpService empService;

    @Autowired
    private StudentService studentService;

    @GetMapping("/empJobData")
    public Result getEmpJobData(){
        log.info("员工职位人数统计");

        JobInfo jobInfo = empService.getJobInfo();
        return Result.success(jobInfo);
    }

    @GetMapping("/empGenderData")
    public Result getEmpGenderData(){
        log.info("员工性别人数统计");

        List<Map<String,Object>> genderInfo = empService.getGenderInfo();
        return Result.success(genderInfo);
    }

    @GetMapping("/studentCountData")
    public Result studentCountData() {
        log.info("班级人数统计...");

        ClazzInfo clazzInfo = studentService.getClazzInfo();
        return Result.success(clazzInfo);
    }

    @GetMapping("/studentDegreeData")
    public Result studentDegreeData() {
        log.info("学员学历统计...");

        List<Map<String,Object>> degreeInfo = studentService.getDegreeInfo();
        return Result.success(degreeInfo);
    }
}
